package core.report.yearReport.bean;

import org.springframework.jdbc.support.rowset.SqlRowSet;

public class WeekSalesReportDataBean extends SalesReportDataBean{
	
	private double avg_item;
	private double avg_cost;


	@Override
	public void setProperties(SqlRowSet rs) {
		this.shopId = rs.getInt("shopId");
		this.shopName = rs.getString("shopName");
		this.attribute_id = rs.getInt("attribute_id");
		this.totalAmount = rs.getDouble("totalAmount");
		this.sale_accomplish = rs.getDouble("sale_accomplish");
//		this.sale_rate = rs.getDouble("sale_rate");
		this.cost_Amount = rs.getDouble("cost_Amount");
		this.cost_rate = rs.getDouble("cost_rate");
		this.cost_accomplish = rs.getDouble("cost_accomplish");
		this.views = rs.getLong("views");
		this.guests = rs.getDouble("guests");
		this.success_rate = rs.getDouble("success_rate");
		this.avg_item = rs.getDouble("avg_item");
		this.avg_cost = rs.getDouble("avg_cost");
		
		this.name = this.shopName;
		
	}

	public void addProperties(SalesReportDataBean bean) {
		WeekSalesReportDataBean data = (WeekSalesReportDataBean)bean;
		this.setTotalAmount(this.getTotalAmount() + data.getTotalAmount());
		this.setSale_accomplish(this.getSale_accomplish()
				+ data.getSale_accomplish());
		this.setSale_rate(this.getSale_rate() + data.getSale_rate());
		this.setCost_Amount(this.getCost_Amount() + data.getCost_Amount());
		this.setCost_rate(this.getCost_rate() + data.getCost_rate());
		this
				.setCost_accomplish(this.getCost_accomplish()
						+ data.getCost_accomplish());
		this.setViews(this.getViews() + data.getViews());
		this.setGuests(this.getGuests() + data.getGuests());
		this.setSuccess_rate(this.getSuccess_rate() + data.getSuccess_rate());
		this.setAvg_item(this.getAvg_item()
				+ data.getAvg_item());
		this.setAvg_cost(this.getAvg_cost() + data.getAvg_cost());
	}


	public String getValueByIndex(int index) {
		String value = "";
		switch (index) {
		case 0:
			value = this.getName();
			break;
		case 1:
			value = this.getTotalAmount() + "";
			break;
		case 2:
			value = this.getSale_accomplish() + "";
			break;
		case 3:
			value = this.getSale_rate() + "";
			break;
		case 4:
			value = this.getCost_Amount() + "";
			break;
		case 5:
			value = this.getCost_rate() + "";
			break;
		case 6:
			value = this.getCost_accomplish() + "";
			break;
		case 7:
			value = this.getViews() + "";
			break;
		case 8:
			value = this.getGuests() + "";
			break;
		case 9:
			value = this.getSuccess_rate() + "";
			break;
		case 10:
			value = this.getAvg_item() + "";
			break;
		case 11:
			value = this.getAvg_cost() + "";
			break;
		}
		return value;
	}

	public double getAvg_item() {
		return avg_item;
	}

	public void setAvg_item(double avg_item) {
		this.avg_item = avg_item;
	}

	public double getAvg_cost() {
		return avg_cost;
	}

	public void setAvg_cost(double avg_cost) {
		this.avg_cost = avg_cost;
	}



}
